/**
 * Copyright 2000 self.com.au
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. (http://www.apache.org/licenses/LICENSE-2.0)
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
 * the specific language governing permissions and limitations under the License.
 *
 * <dhamma-message src="Atisha (11th century Tibetan Buddhist master)">
 * 	The greatest achievement is selflessness. The greatest worth is self-mastery.
 * 	The greatest quality is seeking to serve others. The greatest precept is continual awareness.
 * 	The greatest medicine is the emptiness of everything. The greatest action is not conforming with the worlds ways.
 * 	The greatest magic is transmuting the passions. The greatest generosity is non-attachment.
 * 	The greatest goodness is a peaceful mind. The greatest patience is humility.
 * 	The greatest effort is not concerned with results. The greatest meditation is a mind that lets go.
 * 	The greatest wisdom is seeing through appearances. 
 * </dhamma-message>
 *
 * @author Ashin Wimalajeewa
 */
package self.amigo.tool;

import java.util.ArrayList;
import java.util.List;

import self.amigo.diag.ContextDiagram;
import self.amigo.diag.ScreenSketch;
import self.amigo.diag.bpm.ProcessRoadmap;
import self.amigo.diag.uml.ActivityDiagram;
import self.amigo.diag.uml.ClassDiagram;
import self.amigo.diag.uml.CollaborationDiagram;
import self.amigo.diag.uml.ComponentDiagram;
import self.amigo.diag.uml.DeploymentDiagram;
import self.amigo.diag.uml.PackageDiagram;
import self.amigo.diag.uml.SequenceDiagram;
import self.amigo.diag.uml.StateTransitionDiagram;
import self.amigo.diag.uml.UseCaseDiagram;
import self.amigo.editor.sheet.ButtonSheet;
import self.amigo.editor.sheet.ContextMenuSheet;
import self.amigo.editor.sheet.DiagramSheet;
import self.amigo.editor.sheet.EllipseSheet;
import self.amigo.editor.sheet.InputBoxSheet;
import self.amigo.editor.sheet.LineSheet;
import self.amigo.editor.sheet.RectangleSheet;
import self.amigo.editor.sheet.TextSheet;
import self.amigo.editor.sheet.WindowSheet;
import self.amigo.editor.sheet.bpm.HiFiActivitySheet;
import self.amigo.editor.sheet.bpm.StageSheet;
import self.amigo.editor.sheet.uml.AssociationSheet;
import self.amigo.editor.sheet.uml.CollaborationMessageSheet;
import self.amigo.editor.sheet.uml.ElementaryLinkSheet;
import self.amigo.editor.sheet.uml.LogicalClassSheet;
import self.amigo.editor.sheet.uml.NameAndCompositionCompartmentsSheet;
import self.amigo.editor.sheet.uml.SequenceDiagramElementSheet;
import self.amigo.editor.sheet.uml.StateTransitionSheet;
import self.amigo.editor.sheet.uml.UseCaseSheet;
import self.amigo.editor.tool.ButtonTool;
import self.amigo.editor.tool.ContextMenuTool;
import self.amigo.editor.tool.EllipseTool;
import self.amigo.editor.tool.FreehandTool;
import self.amigo.editor.tool.InputBoxTool;
import self.amigo.editor.tool.LinkTool;
import self.amigo.editor.tool.PolyLineTool;
import self.amigo.editor.tool.RectangleTool;
import self.amigo.editor.tool.ScrollbarTool;
import self.amigo.editor.tool.TextTool;
import self.amigo.editor.tool.WindowTool;
import self.amigo.editor.tool.bpm.HiFiActivityTool;
import self.amigo.editor.tool.bpm.HiFiArtifactTool;
import self.amigo.editor.tool.bpm.HiFiRoleTool;
import self.amigo.editor.tool.bpm.StageTool;
import self.amigo.editor.tool.uml.ActivityDecisionTool;
import self.amigo.editor.tool.uml.ActivityTool;
import self.amigo.editor.tool.uml.ActorTool;
import self.amigo.editor.tool.uml.AssociationTool;
import self.amigo.editor.tool.uml.CollaborationLinkTool;
import self.amigo.editor.tool.uml.CollaborationMessageTool;
import self.amigo.editor.tool.uml.ComponentInstanceTool;
import self.amigo.editor.tool.uml.ComponentTool;
import self.amigo.editor.tool.uml.ConnectionTool;
import self.amigo.editor.tool.uml.DependencyTool;
import self.amigo.editor.tool.uml.EndStateTool;
import self.amigo.editor.tool.uml.GeneralizationTool;
import self.amigo.editor.tool.uml.InterfaceTool;
import self.amigo.editor.tool.uml.LogicalClassTool;
import self.amigo.editor.tool.uml.NodeTool;
import self.amigo.editor.tool.uml.ObjectTool;
import self.amigo.editor.tool.uml.PackageTool;
import self.amigo.editor.tool.uml.RealizationTool;
import self.amigo.editor.tool.uml.SelfReferencingAssociationTool;
import self.amigo.editor.tool.uml.SelfReferencingCollaborationLinkTool;
import self.amigo.editor.tool.uml.SelfReferencingStateTransitionTool;
import self.amigo.editor.tool.uml.SequenceDiagramActorTool;
import self.amigo.editor.tool.uml.SequenceDiagramClassTool;
import self.amigo.editor.tool.uml.SequenceDiagramMessageTool;
import self.amigo.editor.tool.uml.SequenceDiagramObjectTool;
import self.amigo.editor.tool.uml.SequenceDiagramSelfMessageTool;
import self.amigo.editor.tool.uml.StartStateTool;
import self.amigo.editor.tool.uml.StateTool;
import self.amigo.editor.tool.uml.StateTransitionTool;
import self.amigo.editor.tool.uml.SubsystemTool;
import self.amigo.editor.tool.uml.SynchronizationBarTool;
import self.amigo.editor.tool.uml.UseCaseTool;
import self.amigo.elem.ButtonView;
import self.amigo.elem.ContextMenuView;
import self.amigo.elem.EllipseView;
import self.amigo.elem.InputBoxView;
import self.amigo.elem.LinkView;
import self.amigo.elem.PolyElementView;
import self.amigo.elem.PolyLineView;
import self.amigo.elem.RectangleView;
import self.amigo.elem.TextView;
import self.amigo.elem.WindowView;
import self.amigo.elem.bpm.HiFiActivityView;
import self.amigo.elem.bpm.HiFiArtifactView;
import self.amigo.elem.bpm.HiFiRoleView;
import self.amigo.elem.bpm.StageView;
import self.amigo.elem.uml.ActorView;
import self.amigo.elem.uml.AssociationView;
import self.amigo.elem.uml.CollaborationLinkView;
import self.amigo.elem.uml.CollaborationMessageView;
import self.amigo.elem.uml.ComponentInstanceView;
import self.amigo.elem.uml.ComponentView;
import self.amigo.elem.uml.ConnectionView;
import self.amigo.elem.uml.DependencyView;
import self.amigo.elem.uml.EndStateView;
import self.amigo.elem.uml.GeneralizationView;
import self.amigo.elem.uml.InterfaceView;
import self.amigo.elem.uml.LogicalClassView;
import self.amigo.elem.uml.NodeView;
import self.amigo.elem.uml.ObjectView;
import self.amigo.elem.uml.PackageView;
import self.amigo.elem.uml.RealizationView;
import self.amigo.elem.uml.SequenceDiagramActorView;
import self.amigo.elem.uml.SequenceDiagramClassView;
import self.amigo.elem.uml.SequenceDiagramMessageView;
import self.amigo.elem.uml.SequenceDiagramObjectView;
import self.amigo.elem.uml.SequenceDiagramSelfMessageView;
import self.amigo.elem.uml.StartStateView;
import self.amigo.elem.uml.StateTransitionView;
import self.amigo.elem.uml.StateView;
import self.amigo.elem.uml.SubsystemView;
import self.amigo.elem.uml.UseCaseView;
import self.gee.editor.PropertySheetManagerUtils;
import self.gee.editor.ToolsManagerUtils;


final public class RegistrationUtils {
  static private List diagramsSupported = new ArrayList();

  private RegistrationUtils() {
	// nothing to do.
  }

  static public void initialise() {
    registerAgileDiagramTools();
    registerAgilePropertySheets();
  }

  static private void registerDiagramTools( Class diagClass, Class[] tools ) {
    diagramsSupported.add( diagClass );
    int max = tools.length;
    for ( int cntr = 0; cntr < max; cntr++ )
      ToolsManagerUtils.registerDiagramTool( diagClass, tools[cntr] );
  }

  static private void registerScreenSketckTools() {
    Class[] tools = new Class[] {
      WindowTool.class,
      ContextMenuTool.class,
      InputBoxTool.class,
      ButtonTool.class,
      ScrollbarTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( ScreenSketch.class, tools );
  }

  static private void registerContextDiagramTools() {
    Class[] tools = new Class[] {
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( ContextDiagram.class, tools );
  }

  static private void registerProcessRoadmapTools() {
    Class[] tools = new Class[] {
      StageTool.class,
      HiFiActivityTool.class,
      HiFiArtifactTool.class,
      HiFiRoleTool.class,
      ActivityTool.class,
      StartStateTool.class,
      EndStateTool.class,
      SynchronizationBarTool.class,
      StateTransitionTool.class,
      SelfReferencingStateTransitionTool.class,
      ActivityDecisionTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( ProcessRoadmap.class, tools );
  }


  static private void registerPackageDiagramTools() {
    Class[] tools = new Class[] {
      PackageTool.class,
      DependencyTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( PackageDiagram.class, tools );
  }

  static private void registerUseCaseDiagramTools() {
    Class[] tools = new Class[] {
      ActorTool.class,
      UseCaseTool.class,
      AssociationTool.class,
      GeneralizationTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( UseCaseDiagram.class, tools );
  }

  static private void registerCollaborationDiagramTools() {
    Class[] tools = new Class[] {
      ObjectTool.class,
      ActorTool.class,
      LogicalClassTool.class,
      CollaborationLinkTool.class,
      SelfReferencingCollaborationLinkTool.class,
      CollaborationMessageTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( CollaborationDiagram.class, tools );
  }

  static private void registerClassDiagramTools() {
    Class[] tools = new Class[] {
      PackageTool.class,
      ActorTool.class,
      UseCaseTool.class,
      InterfaceTool.class,
      LogicalClassTool.class,
      DependencyTool.class,
      AssociationTool.class,
      SelfReferencingAssociationTool.class,
      GeneralizationTool.class,
      RealizationTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( ClassDiagram.class, tools );
  }

  static private void registerComponentDiagramTools() {
    Class[] tools = new Class[] {
      ComponentTool.class,
      SubsystemTool.class,
      InterfaceTool.class,
      LogicalClassTool.class,
      DependencyTool.class,
      RealizationTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( ComponentDiagram.class, tools );
  }

  static private void registerDeploymentDiagramTools() {
    Class[] tools = new Class[] {
      InterfaceTool.class,
      ComponentInstanceTool.class,
      NodeTool.class,
      DependencyTool.class,
      RealizationTool.class,
      ConnectionTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( DeploymentDiagram.class, tools );
  }

  static private void registerSequenceDiagramTools() {
    Class[] tools = new Class[] {
      SequenceDiagramActorTool.class,
      SequenceDiagramObjectTool.class,
      SequenceDiagramClassTool.class,
      SequenceDiagramMessageTool.class,
      SequenceDiagramSelfMessageTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( SequenceDiagram.class, tools );
  }

  static private void registerStateDiagramTools() {
    Class[] tools = new Class[] {
      StateTool.class,
      StartStateTool.class,
      EndStateTool.class,
      SynchronizationBarTool.class,
      StateTransitionTool.class,
      SelfReferencingStateTransitionTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( StateTransitionDiagram.class, tools );
  }


  static private void registerActivityDiagramTools() {
    Class[] tools = new Class[] {
      ActivityTool.class,
      StartStateTool.class,
      EndStateTool.class,
      SynchronizationBarTool.class,
      StateTransitionTool.class,
      SelfReferencingStateTransitionTool.class,
      ActivityDecisionTool.class,
      TextTool.class,
      RectangleTool.class,
      EllipseTool.class,
      LinkTool.class,
      PolyLineTool.class,
      FreehandTool.class };

    registerDiagramTools( ActivityDiagram.class, tools );
  }

  static private void registerAgileDiagramTools() {
    registerScreenSketckTools();
    registerContextDiagramTools();
    registerProcessRoadmapTools();

    registerPackageDiagramTools();
    registerUseCaseDiagramTools();
    registerClassDiagramTools();
    registerComponentDiagramTools();
    registerDeploymentDiagramTools();
    registerCollaborationDiagramTools();
    registerSequenceDiagramTools();
    registerStateDiagramTools();
    registerActivityDiagramTools();
  }

  static private void registerAgilePropertySheets() {
    PropertySheetManagerUtils.registerPropertySheet( ScreenSketch.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ContextDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ProcessRoadmap.class, DiagramSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( PackageDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( UseCaseDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ClassDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ComponentDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( CollaborationDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( DeploymentDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( SequenceDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( StateTransitionDiagram.class, DiagramSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ActivityDiagram.class, DiagramSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( StageView.class, StageSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( HiFiActivityView.class, HiFiActivitySheet.class );
    PropertySheetManagerUtils.registerPropertySheet( HiFiArtifactView.class, HiFiActivitySheet.class );
    PropertySheetManagerUtils.registerPropertySheet( HiFiRoleView.class, HiFiActivitySheet.class );

    PropertySheetManagerUtils.registerPropertySheet( WindowView.class, WindowSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( InputBoxView.class, InputBoxSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ContextMenuView.class, ContextMenuSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ButtonView.class, ButtonSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( PackageView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( SubsystemView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ComponentView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( ConnectionView.class, ElementaryLinkSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( ObjectView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( CollaborationLinkView.class, ElementaryLinkSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( CollaborationMessageView.class, CollaborationMessageSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( SequenceDiagramObjectView.class, SequenceDiagramElementSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( SequenceDiagramClassView.class, SequenceDiagramElementSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( SequenceDiagramActorView.class, SequenceDiagramElementSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( SequenceDiagramMessageView.class, CollaborationMessageSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( SequenceDiagramSelfMessageView.class, CollaborationMessageSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( StateView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( self.amigo.elem.uml.ActivityView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( StartStateView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( EndStateView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( StateTransitionView.class, StateTransitionSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( ComponentInstanceView.class, NameAndCompositionCompartmentsSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( NodeView.class, NameAndCompositionCompartmentsSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( ActorView.class, LogicalClassSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( UseCaseView.class, UseCaseSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( InterfaceView.class, LogicalClassSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( LogicalClassView.class, LogicalClassSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( DependencyView.class, ElementaryLinkSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( AssociationView.class, AssociationSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( GeneralizationView.class, ElementaryLinkSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( RealizationView.class, ElementaryLinkSheet.class );

    PropertySheetManagerUtils.registerPropertySheet( TextView.class, TextSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( RectangleView.class, RectangleSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( EllipseView.class, EllipseSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( LinkView.class, LineSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( PolyElementView.class, LineSheet.class );
    PropertySheetManagerUtils.registerPropertySheet( PolyLineView.class, LineSheet.class );
  }


  static void testSerialization( Class cls ) throws Exception {
    final Object o1 = cls.newInstance();
    self.lang.ObjectUtils.deepClone( o1 );
  }

//  static public void main( String[] args ) throws Exception {
//    testSerialization(  WindowView.class );
//    testSerialization(  InputBoxView.class );
//    testSerialization(  ContextMenuView.class );
//    testSerialization(  ButtonView.class );
//
//    testSerialization(  PackageView.class );
//    testSerialization(  SubsystemView.class );
//    testSerialization(  ComponentView.class );
//    testSerialization(  ConnectionView.class );
//
//    testSerialization(  ObjectView.class  );
//    testSerialization(  CollaborationLinkView.class );
//    testSerialization(  CollaborationMessageView.class );
//
//    testSerialization(  SequenceDiagramObjectView.class );
//    testSerialization(  SequenceDiagramClassView.class );
//    testSerialization(  SequenceDiagramActorView.class );
//    testSerialization(  SequenceDiagramMessageView.class );
//    testSerialization(  SequenceDiagramSelfMessageView.class );
//
//    testSerialization(  StateView.class );
//    testSerialization(  ActivityView.class );
//    testSerialization(  StartStateView.class );
//    testSerialization(  EndStateView.class );
//    testSerialization(  StateTransitionView.class );
//
//    testSerialization(  ComponentInstanceView.class );
//    testSerialization(  NodeView.class );
//
//    testSerialization(  ActorView.class );
//    testSerialization(  UseCaseView.class );
//    testSerialization(  InterfaceView.class );
//    testSerialization(  LogicalClassView.class );
//
//    testSerialization(  DependencyView.class );
//    testSerialization(  AssociationView.class );
//    testSerialization(  GeneralizationView.class );
//    testSerialization(  RealizationView.class );
//
//    testSerialization(  TextView.class );
//    testSerialization(  RectangleView.class );
//    testSerialization(  EllipseView.class );
//    testSerialization(  LinkView.class );
//    testSerialization(  PolyLineView.class );
//
//    testSerialization(  StageView.class );
//
//    System.out.println("hello");
//  }
}